<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
    /**自己加的样式*/
    .black {
        text-color: #000000;
        font-weight: bold;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-cityMasterList-buyCity" th:object="${cityMasterList}">
        <input id="adCode" name="adCode" th:field="*{adCode}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">全国区县名称：</label>
            <span class="col-sm-7 control-label black" th:text="*{name}"></span>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">省市区聚合：</label>
            <span class="col-sm-7 control-label black" th:text="*{mergerName}"></span>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">最后交易价格：</label>
            <span class="col-sm-7 control-label black" th:text="*{lastPrice}"></span>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">最后交易时间：</label>
            <span class="col-sm-7 control-label black" th:text="*{lastTransactionTime}"></span>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">下一笔支付价格：</label>
            <span class="col-sm-7 control-label black" th:text="*{newBuyPrice}"></span>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">购买用户手机号：</label>
            <div class="col-sm-7">
                <select name="userPhone" class="form-control m-b" th:with="type=${@dict.getType('buy_city_user')}">
                    <option value="">请选择用户</option>
                    <option th:each="e : ${type}" th:text="${e['dictLabel']}" th:value="${e['dictValue']}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="form-control-static col-sm-offset-8">
                <button type="submit" class="btn btn-primary">提交</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "city/cityMasterList"
    $("#form-cityMasterList-buyCity").validate({
        rules: {
            userPhone: {
                required: true,
            },
        },
        submitHandler: function (form) {


            $.modal.confirm("确认要购买该城市吗?", function () {
                $.modal.loading("正在处理中，请稍后...");
                var config = {
                    timeout: 30000,
                    url: prefix + "/buyCity",
                    type: "post",
                    dataType: "json",
                    data: $('#form-cityMasterList-buyCity').serialize(),
                    success: function (result) {
                        if (result.code == web_status.SUCCESS) {
                            layer.msg(result.msg, {
                                icon: $.modal.icon(modal_status.SUCCESS),
                                time: 1000,
                                shade: [0.1, '#8F8F8F']
                            });
                        } else {
                            $.modal.alertError(result.msg);
                        }
                        $.modal.closeLoading();

                    },
                    error: function (data, status, xhr) {
                        layer.msg(data, {
                            icon: $.modal.icon(modal_status.FAIL),
                            time: 1000,
                            shade: [0.1, '#8F8F8F']
                        });
                    }
                };
                $.ajax(config)

            });

        }
    });
</script>
</body>
</html>
